import UnityEngine

class DiscussionManager(MonoBehaviour):
	groupies= []

	def Start():
		pass
	
	def Update():
		pass
	
	def RegisterGroupie(groupie as GameObject):
		if groupie in groupies:
			Debug.LogError('Groupie already registered!')
		else:
			groupies.Push(groupie)
			groupie.transform.parent = self.transform
			RestructureGroupies()
	
	def UnregisterGroupie(groupie as GameObject):
		if not groupie in groupies:
			Debug.LogError('Groupie not registered yet!')
		else:
			groupies.Remove(groupie)
			groupie.transform.parent = null
			RestructureGroupies()
	
	def RestructureGroupies():
		count = 0
		/*
		maxDistance = 0
		for i in range(len(groupies)):
			Debug.Log(i)
			d = groupies[i].collider.radius + groupies[(i + 1) % len(groupies)].collider.radius
			maxDistance = Mathf.Max(d, maxDistance)
		*/
		for i as GameObject in groupies:
			i.transform.localPosition.x = 0.5
			i.transform.localPosition.z = 0
			i.transform.localRotation = Quaternion.identity
			i.transform.RotateAround(transform.position, Vector3.up, count * 360 / len(groupies))
			count += 1
